/*
 * Copyright 2009 David de Mingo
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package org.shalma;

import java.util.Locale;

public enum Language {

	ARABIC("ar", "العربية"), BULGARIAN("bg", "Български"), CHINESE("zh", "中文"), CATALAN(
			"ca", "Català"), CROATIAN("hr", "Hrvatski"), CZECH("cs", "Česky"), DANISH(
			"da", "Dansk"), DUTCH("nl", "Nederlands"), ENGLISH("en", "English"), FILIPINO(
			"fil", "Filipino"), FINNISH("fi", "Suomi"), FRENCH("fr", "Français"), GERMAN(
			"de", "Deutsch"), GREEK("el", "Ελληνικά"), HEBREW("iw", "עברית"), HINDI(
			"hi", "हिन्दी"), INDONESIAN("in", "Indonesia"), ITALIAN("it",
			"Italiano"), JAPANESE("ja", "日本語"), KOREAN("ko", "한국어"), LATVIAN(
			"lv", "Latviešu"), LITHUANIAN("lt", "Lietuvių"), NORWEIGAN("no",
			"Norsk"), PORTUGUESE("pt", "Português"), ROMANIAN("ro", "Română"), RUSSIAN(
			"ru", "Русский"), SPANISH("es", "Español"), SERBIAN("sr", "Српски"), SLOVAK(
			"sk", "Slovenčina"), SLOVENIAN("sl", "Slovenski"), SWEDISH("sv",
			"Svenska"), UKRAINIAN("uk", "Українська"), VIETNAMESE("vi", "Việt");

	private String code;

	private String name;

	private Locale locale;

	private Language(String code, String name) {
		this.code = code;
		this.name = name;
		this.locale = new Locale(code);
	}

	private Language() {
	}

	public String getCode() {
		return code;
	}

	public String getName() {
		return name;
	}

	public Locale getLocale() {
		return locale;
	}

	public static Language getLanguage(String code) {
		for (Language language : values())
			if (language.code.equals(code))
				return language;
		return null;
	}
}
